package yagwl.service.util.svc;

@SuppressWarnings("serial")
public class BaseException extends RuntimeException {

  private ErrorCode errorCode;

  public BaseException(ErrorCode errorCode) {
    super(errorCode.toString());
    this.errorCode = errorCode;
  }

  public BaseException(ErrorCode errorCode, Exception e) {
    super(e.getMessage());
    this.errorCode = errorCode;
  }

  public ErrorCode getErrorCode() {
    return errorCode;
  }

  public static enum ErrorCode {
    // Generic client-side errors that should be handled by the client
    INVALID_NUMBER, //
    REQUIRED_FIELD_MISSING, //
    OBJECT_NOT_FOUND, //
    OBJECT_EXISTS, //
    
    // Internal errors
    INTERNAL_DATABASE_QUERY_ERROR, //
    INTERNAL_TRANSACTION_ERROR, //
    INTERNAL_ENCRYPTION_ERROR, //

    // Server side exceptions that cannot be caught on the UI
    AuthenticationFailed, //
    EmailAddressDoesNotExist, //
    EmailAddressExists, //
    MobileNumberDoesNotExist, //
    MobileNumberExists, //
    OrganizationCodeExists, //
    VerificationCodeNotMatched
  }

}
